<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:p="http://primefaces.prime.com.tr/ui"
       xmlns:c="http://java.sun.com/jsp/jstl/core">
    
    <body>
        
        <ui:composition template="./Test.xhtml">
            

            <ui:define name="content">

                <p:dataTable var="item" value="#{accountBean.listAccount}"
                             paginator="true" rows="10"
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                             rowsPerPageTemplate="5,10,15"
                             selection="selectedAU"
                             selectionMode="single">
                    <f:facet name="header">
                        Show all Account
                    </f:facet>

                    <p:column sortBy="#{item.accountId}" filterBy="#{item.accountId}">
                        <f:facet name="header">
                            <h:outputText value="Account Id" />
                        </f:facet>
                        <h:outputText value="#{item.accountId}" />
                    </p:column>
                    <p:column sortBy="#{item.accountName}" filterBy="#{item.accountName}">
                        <f:facet name="header">
                            <h:outputText value="Account Name" />
                        </f:facet>
                        <h:outputText value="#{item.accountName}">

                        </h:outputText>
                    </p:column>
                    <p:column sortBy="#{item.amount}" filterBy="#{item.amount}">
                        <f:facet name="header">
                            <h:outputText value="Amount"/>
                        </f:facet>
                        <h:outputText value="#{item.amount}">
                        </h:outputText>
                    </p:column>
                  
                    <p:column sortBy="#{item.customer.email}"  filterBy="#{item.customer.email}">
                        <f:facet name="header">
                            <h:outputText value="Email"/>
                        </f:facet>
                        <h:outputText value="#{item.customer.email}">
                        </h:outputText>
                    </p:column>


                    <p:column>
                        <f:facet name="header">
                            Update
                        </f:facet>
                        <h:commandButton action="updateAccount"  value="Update" type="image" image="../resources/images/table/action_edit.gif">
                            <f:setPropertyActionListener value="#{item}"
                                                         target="#{accountBean.ac}" />
                        </h:commandButton>

                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            Delete
                        </f:facet>
                        <p:commandLink ajax="false" onclick="{if (!confirm('Are you sure!')) return false}"
                                       update="pnl,grl"  action="Account" actionListener="#{accountBean.deleteAccount(item)}">
                            <p:graphicImage style="width: 20px" value="../resources/images/table/action_delete.gif"/>

                        </p:commandLink>
                    </p:column>

                </p:dataTable>
            </ui:define>

           

        </ui:composition>
        
    </body>
</html>
